<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: RailsEnvironment</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">RailsEnvironment</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/vendor/rails/railties/lib/commands/plugin_rb.html">
                vendor/rails/railties/lib/commands/plugin.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000173">best_install_method</a>&nbsp;&nbsp;
      <a href="#M000167">default</a>&nbsp;&nbsp;
      <a href="#M000168">default=</a>&nbsp;&nbsp;
      <a href="#M000174">externals</a>&nbsp;&nbsp;
      <a href="#M000175">externals=</a>&nbsp;&nbsp;
      <a href="#M000166">find</a>&nbsp;&nbsp;
      <a href="#M000169">install</a>&nbsp;&nbsp;
      <a href="#M000165">new</a>&nbsp;&nbsp;
      <a href="#M000172">use_checkout?</a>&nbsp;&nbsp;
      <a href="#M000171">use_externals?</a>&nbsp;&nbsp;
      <a href="#M000170">use_svn?</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">root</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000167" class="method-detail">
        <a name="M000167"></a>

        <div class="method-heading">
          <a href="#M000167" class="method-signature">
          <span class="method-name">default</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000167-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000167-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 83</span>
83:   <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">default</span>
84:     <span class="ruby-ivar">@default</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">find</span>
85:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000168" class="method-detail">
        <a name="M000168"></a>

        <div class="method-heading">
          <a href="#M000168" class="method-signature">
          <span class="method-name">default=</span><span class="method-args">(rails_env)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000168-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000168-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 87</span>
87:   <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">default=</span>(<span class="ruby-identifier">rails_env</span>)
88:     <span class="ruby-ivar">@default</span> = <span class="ruby-identifier">rails_env</span>
89:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000166" class="method-detail">
        <a name="M000166"></a>

        <div class="method-heading">
          <a href="#M000166" class="method-signature">
          <span class="method-name">find</span><span class="method-args">(dir=nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000166-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000166-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 75</span>
75:   <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">dir</span>=<span class="ruby-keyword kw">nil</span>)
76:     <span class="ruby-identifier">dir</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">pwd</span>
77:     <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
78:       <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">new</span>(<span class="ruby-identifier">dir</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-value str">'config'</span>, <span class="ruby-value str">'environment.rb'</span>))
79:       <span class="ruby-identifier">dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">dir</span>)
80:     <span class="ruby-keyword kw">end</span>
81:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000165" class="method-detail">
        <a name="M000165"></a>

        <div class="method-heading">
          <a href="#M000165" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(dir)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000165-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000165-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 71</span>
71:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">dir</span>)
72:     <span class="ruby-ivar">@root</span> = <span class="ruby-identifier">dir</span>
73:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000173" class="method-detail">
        <a name="M000173"></a>

        <div class="method-heading">
          <a href="#M000173" class="method-signature">
          <span class="method-name">best_install_method</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000173-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000173-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 125</span>
125:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">best_install_method</span>
126:     <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">:http</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">use_svn?</span>
127:     <span class="ruby-keyword kw">case</span>
128:       <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">use_externals?</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">:externals</span>
129:       <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">use_checkout?</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">:checkout</span>
130:       <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">:export</span>
131:     <span class="ruby-keyword kw">end</span>
132:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000174" class="method-detail">
        <a name="M000174"></a>

        <div class="method-heading">
          <a href="#M000174" class="method-signature">
          <span class="method-name">externals</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000174-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000174-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 134</span>
134:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">externals</span>
135:     <span class="ruby-keyword kw">return</span> [] <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">use_externals?</span>
136:     <span class="ruby-identifier">ext</span> = <span class="ruby-node">`svn propget svn:externals &quot;#{root}/vendor/plugins&quot;`</span>
137:     <span class="ruby-identifier">ext</span>.<span class="ruby-identifier">reject</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">strip</span> <span class="ruby-operator">==</span> <span class="ruby-value str">''</span> }.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> 
138:       <span class="ruby-identifier">line</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp re">/\s+/</span>, <span class="ruby-value">2</span>) 
139:     <span class="ruby-keyword kw">end</span>
140:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000175" class="method-detail">
        <a name="M000175"></a>

        <div class="method-heading">
          <a href="#M000175" class="method-signature">
          <span class="method-name">externals=</span><span class="method-args">(items)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000175-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000175-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 142</span>
142:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">externals=</span>(<span class="ruby-identifier">items</span>)
143:     <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">items</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
144:       <span class="ruby-identifier">items</span> = <span class="ruby-identifier">items</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">name</span>,<span class="ruby-identifier">uri</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;#{name.ljust(29)} #{uri.chomp('/')}&quot;</span>}.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
145:     <span class="ruby-keyword kw">end</span>
146:     <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">open</span>(<span class="ruby-value str">&quot;svn-set-prop&quot;</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
147:       <span class="ruby-identifier">file</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">items</span>)
148:       <span class="ruby-identifier">file</span>.<span class="ruby-identifier">flush</span>
149:       <span class="ruby-identifier">system</span>(<span class="ruby-node">&quot;svn propset -q svn:externals -F \&quot;#{file.path}\&quot; \&quot;#{root}/vendor/plugins\&quot;&quot;</span>)
150:     <span class="ruby-keyword kw">end</span>
151:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000169" class="method-detail">
        <a name="M000169"></a>

        <div class="method-heading">
          <a href="#M000169" class="method-signature">
          <span class="method-name">install</span><span class="method-args">(name_uri_or_plugin)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000169-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000169-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 91</span>
 91:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">install</span>(<span class="ruby-identifier">name_uri_or_plugin</span>)
 92:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name_uri_or_plugin</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
 93:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name_uri_or_plugin</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/:\/\//</span> 
 94:         <span class="ruby-identifier">plugin</span> = <span class="ruby-constant">Plugin</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">name_uri_or_plugin</span>)
 95:       <span class="ruby-keyword kw">else</span>
 96:         <span class="ruby-identifier">plugin</span> = <span class="ruby-constant">Plugins</span>[<span class="ruby-identifier">name_uri_or_plugin</span>]
 97:       <span class="ruby-keyword kw">end</span>
 98:     <span class="ruby-keyword kw">else</span>
 99:       <span class="ruby-identifier">plugin</span> = <span class="ruby-identifier">name_uri_or_plugin</span>
100:     <span class="ruby-keyword kw">end</span>
101:     <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">plugin</span>.<span class="ruby-identifier">nil?</span>
102:       <span class="ruby-identifier">plugin</span>.<span class="ruby-identifier">install</span>
103:     <span class="ruby-keyword kw">else</span>
104:       <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Plugin not found: #{name_uri_or_plugin}&quot;</span>
105:     <span class="ruby-keyword kw">end</span>
106:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000172" class="method-detail">
        <a name="M000172"></a>

        <div class="method-heading">
          <a href="#M000172" class="method-signature">
          <span class="method-name">use_checkout?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000172-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000172-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 118</span>
118:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use_checkout?</span>
119:     <span class="ruby-comment cmt"># this is a bit of a guess. we assume that if the rails environment</span>
120:     <span class="ruby-comment cmt"># is under subversion then they probably want the plugin checked out</span>
121:     <span class="ruby-comment cmt"># instead of exported. This can be overridden on the command line</span>
122:     <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-node">&quot;#{root}/.svn&quot;</span>)
123:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000171" class="method-detail">
        <a name="M000171"></a>

        <div class="method-heading">
          <a href="#M000171" class="method-signature">
          <span class="method-name">use_externals?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000171-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000171-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 114</span>
114:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use_externals?</span>
115:     <span class="ruby-identifier">use_svn?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-node">&quot;#{root}/vendor/plugins/.svn&quot;</span>)
116:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000170" class="method-detail">
        <a name="M000170"></a>

        <div class="method-heading">
          <a href="#M000170" class="method-signature">
          <span class="method-name">use_svn?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000170-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000170-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/railties/lib/commands/plugin.rb, line 108</span>
108:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">use_svn?</span>
109:     <span class="ruby-identifier">require</span> <span class="ruby-value str">'active_support/core_ext/kernel'</span>
110:     <span class="ruby-identifier">silence_stderr</span> {<span class="ruby-value">`svn --version`</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>}
111:     <span class="ruby-operator">!</span><span class="ruby-identifier">$?</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">$?</span>.<span class="ruby-identifier">success?</span>
112:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>